package com.jt;

import com.jt.interceptor.TimeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



@Configuration
public class SpringWebConfig implements WebMvcConfigurer {
    /**
     * 注册拦截器，并定义拦截规则
     * @param registry 负责注册拦截器的对象,这里会将你写的拦截器
     *                 放到一个中容器中(例如list集合)
     */
@Override
    public void addInterceptors(InterceptorRegistry registry){
    registry.addInterceptor(new TimeInterceptor())
           /* .addPathPatterns("/provider/*")
            // .excludePathPatterns排除这个不拦截其他在这个/provider全部拦截
            .excludePathPatterns("/provider/sentinel01");*/
            //只拦截/provider/sentinel01
            .addPathPatterns("/provider/sentinel01");
}
}
